package com.ruoyi.front;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.*;
import com.ijpay.core.enums.TradeType;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMember;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.param.ParamDoc;
import com.ruoyi.system.response.TopicDoc;
import com.ruoyi.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.util.*;

@Controller
@RequestMapping({"/user"})
public class user extends footcontroller {
    @Autowired
    private ISysTypeService iSysTypeService;
    @Autowired
    private ISysFilterService iSysFilterService;
    @Autowired
    private ISysDocService iSysDocService;
    @Autowired
    private ISysTradesetService iSysTradesetService;
    @Autowired
    private ISysMemberService iSysMemberService;
    @Autowired
    private ISysGroupService iSysGroupService;
    @Autowired
    private ISysVgroupService iSysVgroupService;
    @Autowired
    private ISysDocsetService iSysDocsetService;
    @Autowired
    private ISysGlodpotService iSysGlodpotService;
    @Autowired
    private  ISysDownlogService iSysDownlogService;
    @Autowired
    private  ISysFavoriteService iSysFavoriteService;
    @Autowired
    private ISysTopicService iSysTopicService;
    @Autowired
    private  ISysViporderService iSysViporderService;
    @Autowired
    private  ISysGlodorderService iSysGlodorderService;
    @Autowired
    private ISysCashorderService iSysCashorderService;
    @Autowired
    private ISysPaysetService iSysPaysetService;
    @Autowired
    private ISysAlipaysetService iSysAlipaysetService;
    @Autowired
    private ISysOsssetService sysOsssetService;
    @Autowired
    ISysWeixinsetService iSysWeixinsetService; //支付配置
    private HashMap<Long,String> parentIds = new HashMap<Long, String>();
    @GetMapping({"/doclist/{userid}"})
    public String docslist(ModelMap modelMap,@PathVariable("userid") Long userid)
    {

        //SysMember sysMember = ShiroUtils.getSysMember();
        SysMember sysMember = iSysMemberService.selectSysMemberByUserid(userid);
        modelMap.put("sysmember",sysMember);
        getabout(modelMap);
        return "user/user";
    }
    @PostMapping({"/getdoc/{userid}"})
    @ResponseBody
    public TableDataInfo getdoc(@PathVariable("userid") Long userid)
    {
        List<SysTradeset> sysTradesetList = iSysTradesetService.selectSysTradesetList(new SysTradeset());
        startPage();
        SysDoc sysDoc = new SysDoc();
        sysDoc.setUserid(userid);
        List<SysDoc> docList = iSysDocService.selectSysDocList1(sysDoc);
        for (int i = 0;i<docList.size();i++)
        {
            String info = "";
            if(docList.get(i).getIsvip()>0)
                info = info + "<span class=\"tip-bg bg-red\">VIP</span> ";
            if(docList.get(i).getIsimp()>0)
                info = info + "<span class=\"tip-bg bg-blue\">推荐</span> ";
            if(docList.get(i).getIsdel()>0)
                info = info + "<span class=\"tip-bg bg-green\">下架</span>";
            docList.get(i).setTypename(docList.get(i).getTypename().isEmpty()?"<span style=\"color:#f00\">分类已删</span>":docList.get(i).getTypename());
            docList.get(i).setInfo(info);
            docList.get(i).setNote(docList.get(i).getDownpay()==null?"<span class=\"tip-bg bg-red\">禁止下载</span>":docList.get(i).getDownpay().compareTo(BigDecimal.ZERO)==0?"<span class=\"tip-bg bg-pink\">免费</span>":docList.get(i).getDownpay()+sysTradesetList.get(0).getGlodunit());
            //docList.get(i).setInsertdate(DateUtils.dateTime(docList.get(i).getInsertdate());
            //docList.get(i).setKeyword(DateUtils.parseDateToStr("yyyy-mm-dd",docList.get(i).getInsertdate()));
            docList.get(i).setKeyword(docList.get(i).getInsertdate());
            if (docList.get(i).getState()==0)
                docList.get(i).setIndify("<span style=\"color:#196\">待审</span>");
            else if(docList.get(i).getState()==1)
                docList.get(i).setIndify("<span style=\"color:#f60\">通过</span>");
            else
                docList.get(i).setIndify("<span style=\"color:#f00\">失败</span>");



        }
        return getDataTable(docList);
    }
    @GetMapping({"/center"})
    public String center(ModelMap modelMap)
    {
        commonhead(modelMap);
        getabout(modelMap);
        return "user/index";
    }
    //专题
    @GetMapping({"/topic"})
    public String topic(ModelMap modelMap)
    {

        commonhead(modelMap);
        SysMember sysMember = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysGroup sysGroup = iSysGroupService.selectSysGroupByGroupid(sysMember.getGroupid());
        Boolean edit = StringUtils.contains(sysGroup.getRights(),"44");
        Boolean delete = StringUtils.contains(sysGroup.getRights(),"45");
        String editdel = "";
        if(edit)
            editdel = editdel +  "<a href=\"/pub.html?topicid=#topicid\" target=\"_blank\"><i class=\"fa fa-edit fa-lg\"></i></a>  ";
        if(delete)
            editdel = editdel + "<a submit-url=\\'{url:\"/user/center/center/topic_del/#topicid\",tip:\"彻底删除专题?\",back:[\"删除成功\", \"没有权限\"]}\\'><i class=\"fa fa-trash-o fa-lg\"></i></a>";
        modelMap.put("teditdel",editdel);
        getabout(modelMap);
        return "user/topic";
    }
    @PostMapping({"/gettopic/{userid}"})
    @ResponseBody
    public TableDataInfo gettopic(@PathVariable("userid") Long userid)
    {
        List<SysTradeset> sysTradesetList = iSysTradesetService.selectSysTradesetList(new SysTradeset());
        startPage();
        SysTopic sysTopic = new SysTopic();
        sysTopic.setUserid(userid);
        List<SysTopic> topicsList = iSysTopicService.selectTopicByUserid(userid);
        for (int i = 0;i<topicsList.size();i++)
        {

            topicsList.get(i).setKeyword(DateUtils.parseDateToStr("yyyy-mm-dd",topicsList.get(i).getInsertdate()));
            if (topicsList.get(i).getState()==0)
                topicsList.get(i).setKeyword("<span style=\"color:#196\">待审</span>");
            else if(topicsList.get(i).getState()==1)
                topicsList.get(i).setKeyword("<span style=\"color:#f60\">通过</span>");
            else
                topicsList.get(i).setKeyword("<span style=\"color:#f00\">失败</span>");
            List<String> listdocids = Arrays.asList(topicsList.get(i).getDocs().split(","));
            TopicDoc topicDoc = iSysDocService.selectByIdsSel(listdocids);
            if(topicsList.get(i).getDownpay()==null)
            {
                if(topicsList.get(i).getDiscount()==null)
                {
                    topicsList.get(i).setDownpay(Float.parseFloat(new DecimalFormat("#.##").format(topicDoc.getTotalpay())));
                }
                else
                {
                    topicsList.get(i).setDownpay(Float.parseFloat(new DecimalFormat("#.##").format(topicDoc.getTotalpay()*topicsList.get(i).getDiscount())));
                }

            }
            topicsList.get(i).setTotalpay(topicDoc.getTotalpay());
            topicsList.get(i).setTypename(topicsList.get(i).getTypename().isEmpty()?"<span style=\"color:#f00\">分类已删</span>":topicsList.get(i).getTypename());
            topicsList.get(i).setNote(topicsList.get(i).getDownpay()==0?"<span class=\"tip-bg bg-pink\">免费</span>":topicsList.get(i).getDownpay()+sysTradesetList.get(0).getGlodunit());
            topicsList.get(i).setWord(topicsList.get(i).getIsdel()>0?"<span class=\"tip-bg bg-green\">下架</span>":"");

        }
        return getDataTable(topicsList);
    }
    @PostMapping({"/topic_del/{topicid}"})
    @ResponseBody
    public Integer topicdel(ModelMap modelMap,@PathVariable long topicid)
    {
        SysMember sysMember = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysGroup sysGroup = iSysGroupService.selectSysGroupByGroupid(sysMember.getGroupid());
        Boolean delete = StringUtils.contains(sysGroup.getRights(),"45");
        if(!delete)
            return  -1;
        SysTopic sysTopic = iSysTopicService.selectSysTopicByTopicid(topicid);
        if(sysTopic.getUserid() == sysMember.getUserid())
        {

                iSysTopicService.deleteSysTopicByTopicid(topicid); //刪除
                return  1;
        }
        else
        {
            return  -1;
        }
    }
    @GetMapping({"/income"})
    public String docincome(ModelMap modelMap)
    {
        commonhead(modelMap);
        getabout(modelMap);
        return "user/income";
    }
    @GetMapping({"/purchase"})
    public String purchase(ModelMap modelMap)
    {
        commonhead(modelMap);
        getabout(modelMap);
        return "user/purchase";
    }
    @PostMapping({"/purchasedoc"})
    @ResponseBody
    public TableDataInfo getpurchasedoc()
    {

        startPage();
        List<Integer> typeids = new ArrayList<>(Arrays.asList(-30, -31, -32, -40, -41, -42));
        List<SysGlodpot> sysGlodpotList = iSysGlodpotService.findTypeUserid(typeids,ShiroUtils.getSysMember().getUserid(),0);
        for (int i = 0;i<sysGlodpotList.size();i++)
        {
            sysGlodpotList.get(i).setNote(DateUtils.parseDateToStr("yyyy-mm-dd",sysGlodpotList.get(i).getInsertdate()));
            if(sysGlodpotList.get(i).getType() == 30 || sysGlodpotList.get(i).getType() == 31 || sysGlodpotList.get(i).getType() == 32)
            {
                sysGlodpotList.get(i).setRemark("文档阅读");
            }
            if(sysGlodpotList.get(i).getType() == 30 || sysGlodpotList.get(i).getType() == 31 || sysGlodpotList.get(i).getType() == 32)
            {
                sysGlodpotList.get(i).setRemark("文档下载");
            }

        }
        return getDataTable(sysGlodpotList);
    }
    @PostMapping({"/purchasetopic"})
    @ResponseBody
    public TableDataInfo getpurchasetopic()
    {

        startPage();
        List<Integer> typeids = new ArrayList<>(Arrays.asList(-50,-51,-52));
        List<SysGlodpot> sysGlodpotList = iSysGlodpotService.findTypeUserid(typeids,ShiroUtils.getSysMember().getUserid(),1);
        for (int i = 0;i<sysGlodpotList.size();i++)
        {

            sysGlodpotList.get(i).setRemark("专题下载");
        }
        return getDataTable(sysGlodpotList);
    }
    @PostMapping({"/purchasereward"})
    @ResponseBody
    public TableDataInfo getpurchasereward()
    {

        startPage();
        List<Integer> typeids = new ArrayList<>(Arrays.asList(-21));
        List<SysGlodpot> sysGlodpotList = iSysGlodpotService.findTypeUserid(typeids,ShiroUtils.getSysMember().getUserid(),2);
        for (int i = 0;i<sysGlodpotList.size();i++)
        {

            sysGlodpotList.get(i).setRemark("悬赏");
        }
        return getDataTable(sysGlodpotList);
    }
    @GetMapping({"/down"})
    public String down(ModelMap modelMap)
    {
        commonhead(modelMap);
        getabout(modelMap);
        return "user/down";
    }
    @PostMapping({"/docdown"})
    @ResponseBody
    public TableDataInfo getdocdown()
    {

        startPage();
        SysDownlog sysDownlog = new SysDownlog();
        sysDownlog.setUserid(ShiroUtils.getSysMember().getUserid());
        sysDownlog.setCate(0);
        List<SysDownlog> sysDownlogList = iSysDownlogService.selectSysDownlogList(sysDownlog);
        for (int i = 0;i<sysDownlogList.size();i++)
        {
            sysDownlogList.get(i).setRemark(DateUtils.parseDateToStr("yyyy-mm-dd",sysDownlogList.get(i).getInsertdate()));


        }
        return getDataTable(sysDownlogList);
    }
    @PostMapping({"/topicdown"})
    @ResponseBody
    public TableDataInfo gettopicdown()
    {
        startPage();
        SysDownlog sysDownlog = new SysDownlog();
        sysDownlog.setUserid(ShiroUtils.getSysMember().getUserid());
        sysDownlog.setCate(1);
        List<SysDownlog> sysDownlogList = iSysDownlogService.selectSysDownlogList(sysDownlog);
        for (int i = 0;i<sysDownlogList.size();i++)
        {
            sysDownlogList.get(i).setRemark(DateUtils.parseDateToStr("yyyy-mm-dd",sysDownlogList.get(i).getInsertdate()));


        }
        return getDataTable(sysDownlogList);
    }
    @GetMapping({"/favorite"})
    public String favorite(ModelMap modelMap)
    {
        commonhead(modelMap);
        getabout(modelMap);
        return "user/favorite";
    }

    @PostMapping({"/docfavorite"})
    @ResponseBody
    public TableDataInfo getdocfavorite()
    {
        startPage();
        SysFavorite sysFavorite = new SysFavorite();
        sysFavorite.setUserid(ShiroUtils.getSysMember().getUserid());
        sysFavorite.setCate(0);
        List<SysFavorite> sysFavoriteList = iSysFavoriteService.selectSysFavoriteList(sysFavorite);
        for (int i = 0;i<sysFavoriteList.size();i++)
        {
            sysFavoriteList.get(i).setRemark(DateUtils.parseDateToStr("yyyy-mm-dd",sysFavoriteList.get(i).getInsertdate()));


        }
        return getDataTable(sysFavoriteList);
    }
    @PostMapping({"/topicfavorite"})
    @ResponseBody
    public TableDataInfo gettopicfavorite()
    {

        startPage();
        SysFavorite sysFavorite = new SysFavorite();
        sysFavorite.setUserid(ShiroUtils.getSysMember().getUserid());
        sysFavorite.setCate(1);
        List<SysFavorite> sysFavoriteList = iSysFavoriteService.selectSysFavoriteList(sysFavorite);
        for (int i = 0;i<sysFavoriteList.size();i++)
        {
            sysFavoriteList.get(i).setRemark(DateUtils.parseDateToStr("yyyy-mm-dd",sysFavoriteList.get(i).getInsertdate()));


        }
        return getDataTable(sysFavoriteList);
    }
    @PostMapping({"/rewardfavorite"})
    @ResponseBody
    public TableDataInfo getrewardfavorite()
    {

        startPage();
        SysFavorite sysFavorite = new SysFavorite();
        sysFavorite.setUserid(ShiroUtils.getSysMember().getUserid());
        sysFavorite.setCate(2);
        List<SysFavorite> sysFavoriteList = iSysFavoriteService.selectSysFavoriteList(sysFavorite);
        for (int i = 0;i<sysFavoriteList.size();i++)
        {
            sysFavoriteList.get(i).setRemark(DateUtils.parseDateToStr("yyyy-mm-dd",sysFavoriteList.get(i).getInsertdate()));


        }
        return getDataTable(sysFavoriteList);
    }
    @PostMapping({"/incomedoc"})
    @ResponseBody
    public TableDataInfo getincomedoc()
    {

        startPage();
        List<Integer> typeids = new ArrayList<>(Arrays.asList(30, 31, 32, 40, 41, 42));
        List<SysGlodpot> sysGlodpotList = iSysGlodpotService.findTypeUserid(typeids,ShiroUtils.getSysMember().getUserid(),0);
        for (int i = 0;i<sysGlodpotList.size();i++)
        {
           sysGlodpotList.get(i).setNote(DateUtils.parseDateToStr("yyyy-mm-dd",sysGlodpotList.get(i).getInsertdate()));
           if(sysGlodpotList.get(i).getType() == 30 || sysGlodpotList.get(i).getType() == 31 || sysGlodpotList.get(i).getType() == 32)
           {
               sysGlodpotList.get(i).setRemark("文档阅读");
           }
           if(sysGlodpotList.get(i).getType() == 30 || sysGlodpotList.get(i).getType() == 31 || sysGlodpotList.get(i).getType() == 32)
           {
                sysGlodpotList.get(i).setRemark("文档下载");
           }

        }
        return getDataTable(sysGlodpotList);
    }
    @PostMapping({"/incometopic"})
    @ResponseBody
    public TableDataInfo getincometopic()
    {

        startPage();
        List<Integer> typeids = new ArrayList<>(Arrays.asList(50,51,52));
        List<SysGlodpot> sysGlodpotList = iSysGlodpotService.findTypeUserid(typeids,ShiroUtils.getSysMember().getUserid(),1);
        for (int i = 0;i<sysGlodpotList.size();i++)
        {

                sysGlodpotList.get(i).setRemark("专题下载");
        }
        return getDataTable(sysGlodpotList);
    }
    @PostMapping({"/incomereward"})
    @ResponseBody
    public TableDataInfo getinincomereward()
    {

        startPage();
        List<Integer> typeids = new ArrayList<>(Arrays.asList(21));
        List<SysGlodpot> sysGlodpotList = iSysGlodpotService.findTypeUserid(typeids,ShiroUtils.getSysMember().getUserid(),2);
        for (int i = 0;i<sysGlodpotList.size();i++)
        {

            sysGlodpotList.get(i).setRemark("悬赏");
        }
        return getDataTable(sysGlodpotList);
    }
    @PostMapping({"/incomeinvite"})
    @ResponseBody
    public TableDataInfo getincomeinvite()
    {

        startPage();
        List<Integer> typeids = new ArrayList<>(Arrays.asList(11,12));
        List<SysGlodpot> sysGlodpotList = iSysGlodpotService.findTypeUserid(typeids,ShiroUtils.getSysMember().getUserid(),2);
        for (int i = 0;i<sysGlodpotList.size();i++)
        {

            if(sysGlodpotList.get(i).getType() == 11 )
            {
                sysGlodpotList.get(i).setRemark("注册奖励");
            }
            if(sysGlodpotList.get(i).getType() == 12 )
            {
                sysGlodpotList.get(i).setRemark("分红奖励");
            }
        }
        return getDataTable(sysGlodpotList);
    }
    //
    @PostMapping({"/center/doc_del/{docid}"})
    @ResponseBody
    public Integer docdel(ModelMap modelMap,@PathVariable long docid)
    {
        SysMember sysMember = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysGroup sysGroup = iSysGroupService.selectSysGroupByGroupid(sysMember.getGroupid());
        Boolean delete = StringUtils.contains(sysGroup.getRights(),"15");
        if(!delete)
            return  -1;
        SysDoc sysDoc = iSysDocService.selectSysDocByDocid(docid);
        String docpath = sysDoc.getPath();
        if(sysDoc.getUserid() == sysMember.getUserid())
        {
            if(!StringUtils.isEmpty(docpath))
            {
                iSysDocService.deleteSysDocByDocid(docid); //刪除
                String pre = Constants.RESOURCE_PREFIX;
                String dirname = RuoYiConfig.getProfile();
                String srcurl = dirname + docpath.replace(pre,"");
                String path = docpath.replace(pre+"/","");
                String aliyun_src = path.substring(0,path.indexOf(".")) + "/";
                //aliyun_src = aliyun_src.substring(1);
                SysOssset sysOssset;
                sysOssset = sysOsssetService.selectSysOsssetList(new SysOssset()).get(0);
                OSS ossClient = new OSSClientBuilder().build(sysOssset.getEndpoint(), sysOssset.getKeyid(), sysOssset.getKeysecret());
                if(new File(srcurl).exists()) {
                    String srcpath  = srcurl.substring(0,srcurl.indexOf(".")) + "/";
                    FileUtils.deleteFile(srcurl);
                    FileUtils.deleteFolder(new File(srcpath));
                }
                else if(sysOssset.getState()>0&&ossFileExist(path)) {
                    ossClient.deleteObject(sysOssset.getBucket(), path);
                    String dirPrefix = aliyun_src; // 假设你要删除的是名为"folder"的目录下的所有文件
                    ListObjectsRequest listObjectsRequest = new ListObjectsRequest(sysOssset.getBucket()).withPrefix(dirPrefix);
                    listObjectsRequest.setMaxKeys(1000); // 最大返回1000个结果，根据需要调整
                    List<String> keysToDelete = new ArrayList<>();
                    for (OSSObjectSummary objectSummary : ossClient.listObjects(listObjectsRequest).getObjectSummaries()) {
                        keysToDelete.add(objectSummary.getKey()); // 添加每个对象的key到列表中，以便一次性删除
                    }
                    if (!keysToDelete.isEmpty()) {
                        DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(sysOssset.getBucket()).withKeys(keysToDelete);
                        DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(deleteObjectsRequest);
                        System.out.println("Deleted objects: " + deleteObjectsResult.getDeletedObjects());
                    } else {
                        System.out.println("No objects to delete.");
                    };
                    ossClient.deleteObject(sysOssset.getBucket(), aliyun_src);
                    ossClient.shutdown();
                }

                return  1;
            }
        }
        else
        {
            return  -1;
        }
        return  -1;
    }
    //修改文档
    @GetMapping ({"/center/editdoc/{docid}"})
    public String docedit(ModelMap modelMap,@PathVariable long docid)
    {
        SysMember sysMember = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysGroup sysGroup = iSysGroupService.selectSysGroupByGroupid(sysMember.getGroupid());
        SysDoc sysDoc = iSysDocService.selectSysDocByDocid(docid);
        List<SysType> sysTypeList = iSysTypeService.selectSysTypeList(new SysType());
        List<SysDocset> sysDocsetList = iSysDocsetService.selectSysDocsetList(new SysDocset());
        List<SysTradeset> sysTradesets = iSysTradesetService.selectSysTradesetList(new SysTradeset());
        HashMap typenameList = findParentIdsById(sysDoc.getTypeid(),sysTypeList);
        String ids = "";
        String typeNames = "";


        List<Map.Entry<Long,String>> listids=new ArrayList<>(parentIds.entrySet());

        // 对哈希表的值进行排序
        // 对list进行排序，并通过Comparator传入自定义的排序规则
        Collections.sort(listids, new Comparator<Map.Entry<Long, String>>() {
            @Override
            public int compare(Map.Entry<Long, String> o1, Map.Entry<Long, String> o2) {
                return o1.getKey().intValue()-o2.getKey().intValue();
            }
        });
        Iterator<Map.Entry<Long,String>> iterator=listids.iterator();
        while(iterator.hasNext()){
            Map.Entry<Long,String> ite= iterator.next();
            ids = ids + String.valueOf(ite.getKey())+"-";
            typeNames = typeNames +ite.getValue()+">";
        }

        /********************/
        HashMap<Long, SysType> map=new HashMap<Long, SysType>();
        HashMap<Long, List<SysType>> hasharrlist = new HashMap<Long,List<SysType>>();
        List<SysType> tem = new ArrayList<SysType>();
        for (int i = 0; i < sysTypeList.size(); i++) {
            map.put(sysTypeList.get(i).getTypeid(),sysTypeList.get(i));
        }
        for (Map.Entry<Long,SysType> entry : map.entrySet()) {

            if(hasharrlist.containsKey(entry.getValue().getPtypeid())) {
                hasharrlist.get(entry.getValue().getPtypeid()).add(entry.getValue());
            }
            else {
                tem.clear();
                tem.add(entry.getValue());
                List<SysType> list = new ArrayList<SysType>(tem);
                hasharrlist.put(entry.getValue().getPtypeid(),list);
            }
        }
        /********************/
        /************fliter*********************/
        String[] itemsArray = sysDoc.getFilter().split("\\.");
        List<String> itemsList = Arrays.asList(itemsArray);
        List<SysFilter> sysFilterList = iSysFilterService.selectByIdsSel(itemsList);
        HashMap<Long,SysFilter> hashMapFliter = new HashMap<>();
        List<String> pids = new ArrayList<>();
        List<SysFilter> temFilter = new ArrayList<SysFilter>();
        HashMap<Long, List<SysFilter>> hasharrlist1 = new HashMap<Long,List<SysFilter>>();
        for (int i=0;i<sysFilterList.size();i++)
        {
            hashMapFliter.put(sysFilterList.get(i).getPid(),sysFilterList.get(i));
            pids.add(String.valueOf(sysFilterList.get(i).getPid()));
        }
        List<SysFilter> sysFilters = iSysFilterService.selectByIds(pids);
        for (int i = 0; i < sysFilters.size(); i++) {
            if(hasharrlist1.containsKey(sysFilters.get(i).getPid())) {
                hasharrlist1.get(sysFilters.get(i).getPid()).add(sysFilters.get(i));
            }
            else {
                temFilter.clear();
                temFilter.add(sysFilters.get(i));
                List<SysFilter> list = new ArrayList<SysFilter>(temFilter);
                hasharrlist1.put(sysFilters.get(i).getPid(),list);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < hasharrlist1.get(0l).size(); i++) {
            //filter_str += '<div class="doc-filter"><label>' + i +hasharrlist.get(0).get(i).getName()+ '</label><div class="ui-dropdown"><div>请选择...</div><ul>';
            sb.append("<div class=\"doc-filter\"><label>");
            sb.append(hasharrlist1.get(0l).get(i).getName());
            sb.append("</label><div class=\"ui-dropdown\"><div>"+hashMapFliter.get(hasharrlist1.get(0l).get(i).getId()).getName()+"</div><ul>");
            for (int j = 0; j < hasharrlist1.get(hasharrlist1.get(0l).get(i).getId()).size(); j++) {
                sb.append("<li data-val=\"");
                sb.append(hasharrlist1.get(hasharrlist1.get(0l).get(i).getId()).get(j).getId());
                sb.append("\">");
                sb.append(hasharrlist1.get(hasharrlist1.get(0l).get(i).getId()).get(j).getName());
            }
            sb.append("</ul><input name=\"filter[]\" type=\"hidden\" value=\""+hashMapFliter.get(hasharrlist1.get(0l).get(i).getId()).getId()+"\"><i></i></div></div>");
        }
        modelMap.put("filter",sb.toString());
        /*******************************/
        modelMap.put("type1",ids.substring(0,ids.length()-1));
        modelMap.put("type2",typeNames.substring(0,typeNames.length()-1));
        modelMap.put("json", JSONObject.toJSONString(hasharrlist));
        modelMap.put("systradesets",sysTradesets.get(0));
        modelMap.put("sysdocset",sysDocsetList.get(0));
        modelMap.put("doc",sysDoc);
        modelMap.put("ugroup",sysGroup);
        getabout(modelMap);
        return "doc/edit";
    }
    //保存文档
    @PostMapping ({"/center/editsave"})
    @ResponseBody
    public boolean editsave(ParamDoc paramDoc)
    {
        System.out.println(paramDoc);
        SysDoc sysDoc = new SysDoc();
        sysDoc.setDocid(paramDoc.getDocid());
        sysDoc.setTitle(paramDoc.getTitle());
        sysDoc.setKeyword(UnzipAndListFilesUtils.fenci(paramDoc.getKeyword()));
        sysDoc.setWord(paramDoc.getWord());
        sysDoc.setFilter(StringUtils.arrayTostr(paramDoc.getFilter(),"."));
        sysDoc.setTypeid(StringUtils.lastArray(paramDoc.getTypeid()));
        sysDoc.setReadpay(paramDoc.getReadpay());
        sysDoc.setPreview(paramDoc.getPreview());
        sysDoc.setDownpay(paramDoc.getDownpay());
        if(iSysDocService.editSysDoc(sysDoc)>0)
            return true;
        else
            return false;
    }
    //订单
    @GetMapping({"/order"})
    public String order(ModelMap modelMap)
    {
        commonhead(modelMap);
        getabout(modelMap);
        return "user/order";
    }
    @PostMapping({"/order_vip"})
    @ResponseBody
    public TableDataInfo getordervip()
    {

        startPage();
        SysViporder sysViporder = new SysViporder();
        sysViporder.setUserid(ShiroUtils.getSysMember().getUserid());
        List<SysViporder> sysViporderList = iSysViporderService.selectSysViporderList1(sysViporder);
        for (int i=0;i<sysViporderList.size();i++)
        {
            switch (sysViporderList.get(i).getFrom()) {
                case 1:
                    sysViporderList.get(i).setSstr("<span class=\"tip-bg bg-green\">微信</span>");
                    break;
                case 2:
                    sysViporderList.get(i).setSstr("<span class=\"tip-bg bg-blue\">支付宝</span>");
                    break;
                case 3:
                    sysViporderList.get(i).setSstr("<span class=\"tip-bg bg-yellow\">其他</span>");
                    break;
            }
            switch (sysViporderList.get(i).getState()) {
                case 0:
                    sysViporderList.get(i).setFstr("<span style=\"color:#196\">未付款</span>");
                    break;
                case 1:
                    sysViporderList.get(i).setFstr("<span style=\"color:#f60\">已付款</span>");
                    break;
                case 2:
                    sysViporderList.get(i).setFstr("<span style=\"color:#f60\">完成</span>");
                    break;
                default:
                    sysViporderList.get(i).setFstr("");
                    break;
            }


        }
        return getDataTable(sysViporderList);
    }
    //order_gold
    @PostMapping({"/order_glod"})
    @ResponseBody
    public TableDataInfo getorderglod()
    {

        startPage();
        SysGlodorder sysViporder = new SysGlodorder();
        sysViporder.setUserid(ShiroUtils.getSysMember().getUserid());
        List<SysGlodorder> sysViporderList = iSysGlodorderService.selectSysGlodorderList(sysViporder);
        for (int i=0;i<sysViporderList.size();i++)
        {
            switch (sysViporderList.get(i).getFrom()) {
                case 1:
                    sysViporderList.get(i).setSstr("<span class=\"tip-bg bg-green\">微信</span>");
                    break;
                case 2:
                    sysViporderList.get(i).setSstr("<span class=\"tip-bg bg-blue\">支付宝</span>");
                    break;
                case 3:
                    sysViporderList.get(i).setSstr("<span class=\"tip-bg bg-yellow\">其他</span>");
                    break;
            }
            switch (sysViporderList.get(i).getState()) {
                case 0:
                    sysViporderList.get(i).setFstr("<span style=\"color:#196\">未付款</span>");
                    break;
                case 1:
                    sysViporderList.get(i).setFstr("<span style=\"color:#f60\">已付款</span>");
                    break;
                case 2:
                    sysViporderList.get(i).setFstr("<span style=\"color:#f60\">完成</span>");
                    break;
                default:
                    sysViporderList.get(i).setFstr("");
                    break;
            }


        }
        return getDataTable(sysViporderList);
    }
    //order_cash
    @PostMapping({"/order_cash"})
    @ResponseBody
    public TableDataInfo getordercash()
    {

        startPage();
        SysCashorder sysViporder = new SysCashorder();
        sysViporder.setUserid(ShiroUtils.getSysMember().getUserid());
        List<SysCashorder> sysViporderList = iSysCashorderService.selectSysCashorderList(sysViporder);
        for (int i=0;i<sysViporderList.size();i++)
        {
            switch (sysViporderList.get(i).getFrom()) {
                case 1:
                    sysViporderList.get(i).setSstr("<span class=\"tip-bg bg-green\">微信</span>");
                    break;
                case 2:
                    sysViporderList.get(i).setSstr("<span class=\"tip-bg bg-blue\">支付宝</span>");
                    break;
                case 3:
                    sysViporderList.get(i).setSstr("<span class=\"tip-bg bg-yellow\">其他</span>");
                    break;
            }
            switch (sysViporderList.get(i).getTradestate()) {
                case 0:
                    sysViporderList.get(i).setTstr("<span style=\"color:#f60\">未打款</span>");
                    break;
                case 1:
                    sysViporderList.get(i).setTstr("<span style=\"color:#129A5C\">已付款</span>");
                    break;
            }
            switch (sysViporderList.get(i).getState()) {
                case 0:
                    sysViporderList.get(i).setFstr("<span style=\"color:#196\">待审核</span>");
                    break;
                case 1:
                    sysViporderList.get(i).setFstr("<span style=\"color:#f60\">审核通过</span>");
                    break;
                case 2:
                    sysViporderList.get(i).setFstr("<span style=\"color:#f00\">审核未过</span>");
                    break;
                default:
                    sysViporderList.get(i).setFstr("");
                    break;
            }


        }
        return getDataTable(sysViporderList);
    }
    //用户组
    @GetMapping({"/group"})
    public String group(ModelMap modelMap)
    {
        commonhead(modelMap);
        SysMember sysMember = ShiroUtils.getSysMember();
        SysGroup ugroup = iSysGroupService.selectSysGroupByGroupid(ShiroUtils.getSysMember().getGroupid());

        SysVgroup vgroup = iSysVgroupService.selectSysVgroupByVgroupid(ShiroUtils.getSysMember().getVgroupid());
        if(vgroup==null)
        {
            vgroup = new SysVgroup();
            vgroup.setVgroupid(0l);
        }
        List<SysGroup> sysGroupList = iSysGroupService.selectSysGroupList(new SysGroup());
        List<SysVgroup> sysVgroupList = iSysVgroupService.selectSysVgroupList(new SysVgroup());
        SysDoc sysDoc = new SysDoc();
        sysDoc.setUserid(ShiroUtils.getSysMember().getUserid());
        List<SysDoc> sysDocList = new ArrayList<>();
        sysDocList = iSysDocService.selectSysDocList(sysDoc);
        Integer doccount = sysDocList.size();
        SysGroup togroup = null;
        if(ShiroUtils.getSysMember().getUserid()>1)
        {

        }
        modelMap.put("doc_count",doccount);
        modelMap.put("togroup",togroup);
        modelMap.put("ugroup",ugroup);
        modelMap.put("vgroup",vgroup);
        modelMap.put("groups",sysGroupList);
        modelMap.put("vgroups",sysVgroupList);
        modelMap.put("user",sysMember);
        getabout(modelMap);
        return "user/group";
    }
    @GetMapping({"/vip"})
    public String vip(ModelMap modelMap)
    {
        commonhead(modelMap);
        List<SysVgroup> sysVgroupList = iSysVgroupService.selectSysVgroupList(new SysVgroup());
        SysVgroup sysVgroup = new SysVgroup();
        sysVgroup.setSuggest(1l);
        SysVgroup suggest = new SysVgroup();
        suggest = iSysVgroupService.selectSysVgroupList(sysVgroup).get(0);
        if(suggest==null)
            suggest.setVgroupid(0l);
        SysPayset payset = iSysPaysetService.selectSysPaysetList(new SysPayset()).get(0);
        Integer  isewm = iSysAlipaysetService.selectSysAlipaysetList(new SysAlipayset()).get(0).getIsewm();
        modelMap.put("vipgroup",sysVgroupList);
        modelMap.put("suggest",suggest);
        modelMap.put("payset",payset);
        modelMap.put("isewm",isewm);
        getabout(modelMap);
        List<SysWeixinset> sysWeixinsetList = iSysWeixinsetService.selectSysWeixinsetList(new SysWeixinset());
        modelMap.put("paysetlist",sysWeixinsetList);
        return "user/vip";
    }
    //检查vip付款状态
    @GetMapping({"/vippaystate/{vgroupid}"})
    @ResponseBody
    public String vippaystate(@PathVariable Long vgroupid)
    {
        SysViporder sysViporder = new SysViporder();
        sysViporder.setUserid(ShiroUtils.getSysMember().getUserid());
        sysViporder.setVgroupid(vgroupid);
        sysViporder.setState(1);
        sysViporder.setCurrentsecond(DateUtil.currentSeconds());
        List<SysViporder> sysViporderList = iSysViporderService.selectSysViporderList(sysViporder);
        if(sysViporderList.size()>0)
            return sysViporderList.get(0).getOrderid();
        else
            return  "";
    }
    //开通成功提示信息
    @GetMapping({"/vippayfinish/{orderid}"})
    public String vippayfinish(ModelMap modelMap,@PathVariable String orderid)
    {
        commonhead(modelMap);
        SysViporder sysViporder = iSysViporderService.selectSysViporderByOrderid(orderid);
        modelMap.put("order",sysViporder);
        getabout(modelMap);
        return  "user/vippayfinish";
    }
    //我的账户
    @GetMapping({"/account"})
    public String account(ModelMap modelMap)
    {
        commonhead(modelMap);
        SysMember sysMember = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysGroup ugroup = iSysGroupService.selectSysGroupByGroupid(ShiroUtils.getSysMember().getGroupid());
        SysVgroup vgroup = iSysVgroupService.selectSysVgroupByVgroupid(ShiroUtils.getSysMember().getVgroupid());
        if(vgroup==null)
        {
            vgroup = new SysVgroup();
            vgroup.setVgroupid(0l);
        }
        modelMap.put("tradeset",iSysTradesetService.selectSysTradesetList(new SysTradeset()).get(0));
        modelMap.put("ugroup",ugroup);
        modelMap.put("vgroup",vgroup);
        modelMap.put("user",sysMember);
        getabout(modelMap);
        return "user/account";
    }
    //修改信息
    @PostMapping({"/account"})
    @ResponseBody
    public Integer paccount(SysMember sysMember)
    {
        sysMember.setUserid(ShiroUtils.getSysMember().getUserid());
        return iSysMemberService.updateSysMember(sysMember);

    }
    //充值
    @GetMapping({"/glodpay"})
    public String glodpay(ModelMap modelMap)
    {
        commonhead(modelMap);
        List<SysVgroup> sysVgroupList = iSysVgroupService.selectSysVgroupList(new SysVgroup());
        SysVgroup sysVgroup = new SysVgroup();
        sysVgroup.setSuggest(1l);
        SysVgroup suggest = new SysVgroup();
        suggest = iSysVgroupService.selectSysVgroupList(sysVgroup).get(0);
        if(suggest==null)
            suggest.setVgroupid(0l);
        SysPayset payset = iSysPaysetService.selectSysPaysetList(new SysPayset()).get(0);
        Integer  isewm = iSysAlipaysetService.selectSysAlipaysetList(new SysAlipayset()).get(0).getIsewm();
        modelMap.put("tradeset",iSysTradesetService.selectSysTradesetList(new SysTradeset()).get(0));
        modelMap.put("vipgroup",sysVgroupList);
        modelMap.put("suggest",suggest);
        modelMap.put("payset",payset);
        modelMap.put("isewm",isewm);
        getabout(modelMap);
        List<SysWeixinset> sysWeixinsetList = iSysWeixinsetService.selectSysWeixinsetList(new SysWeixinset());
        modelMap.put("paysetlist",sysWeixinsetList);
        return "user/glodpay";
    }
    //检查充值状态
    @GetMapping({"/glodpaystate/{cash}"})
    @ResponseBody
    public String glodpaystate(@PathVariable String cash)
    {
        SysGlodorder sysViporder = new SysGlodorder();
        sysViporder.setUserid(ShiroUtils.getSysMember().getUserid());
        sysViporder.setCurrentsecond(DateUtil.currentSeconds());
        sysViporder.setState(1);
        List<SysGlodorder> sysViporderList = iSysGlodorderService.selectSysGlodorderList(sysViporder);
        if(sysViporderList.size()>0)
            return sysViporderList.get(0).getOrderid();
        else
            return  "";
    }
    //充值成功
    @GetMapping({"/glodpayfinish/{orderid}"})
    public String glodpayfinish(ModelMap modelMap,@PathVariable String orderid)
    {
        commonhead(modelMap);
        SysGlodorder sysViporder = iSysGlodorderService.selectSysGlodorderByOrderid(orderid);
        modelMap.put("order",sysViporder);
        modelMap.put("tradeset",iSysTradesetService.selectSysTradesetList(new SysTradeset()).get(0));
        getabout(modelMap);
        return  "user/glodpayfinish";
    }
    //兑换
    @GetMapping(value = {"/change"})
    public String change(ModelMap model) {
        commonhead(model);
        SysMember user = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysTradeset tradeset = iSysTradesetService.selectSysTradesetList(new SysTradeset()).get(0);
        SysGroup sysGroup = iSysGroupService.selectSysGroupByGroupid(user.getGroupid());
        String message = "";
        if(!StringUtils.contains(sysGroup.getRights(),"81"))
            message = "提示：您没有积分兑换权限";
        if(user.getPoints()<tradeset.getPointout())
            message = "提示：您的积分需要 >= "+tradeset.getPointout()+"才能进行兑换";
        model.put("message",message);
        model.put("tradeset",tradeset);
        model.put("user",user);
        getabout(model);
        return "user/change";
    }
    @PostMapping(value = {"/changeout"})
    public String changeout(@RequestParam("points") Long points, ModelMap model) {
        commonhead(model);
        SysMember user = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysTradeset tradeset = iSysTradesetService.selectSysTradesetList(new SysTradeset()).get(0);
        SysGroup sysGroup = iSysGroupService.selectSysGroupByGroupid(user.getGroupid());
        String message = "";
        if(points<=user.getPoints()&&points>=tradeset.getPointout())
        {
            Float glods = tradeset.getPointrate()*points;
            iSysMemberService.updateGlod(user.getUserid(), BigDecimal.valueOf(glods));//增加金币
            iSysMemberService.updatePoint(user.getUserid(),-points);
            getabout(model);
            return "redirect:/user/center";
        }
        else {
            message = "您最多兑换 " + user.getPoints() + "积分";
            model.put("message",message);
            model.put("tradeset",tradeset);
            model.put("user",user);
            getabout(model);
            return "user/cash";
        }
    }
    //提现
    @GetMapping(value = {"/cash"})
    public String cash(ModelMap model) {
        commonhead(model);
        SysMember user = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysTradeset tradeset = iSysTradesetService.selectSysTradesetList(new SysTradeset()).get(0);
        SysGroup sysGroup = iSysGroupService.selectSysGroupByGroupid(user.getGroupid());
        SysCashorder sysCashorder = new SysCashorder();
        sysCashorder.setUserid(ShiroUtils.getSysMember().getUserid());
        sysCashorder.setState(0);
        String message = "";
        if(!StringUtils.contains(sysGroup.getRights(),"2"))
            message = "提示：您没有提现权限";
        if(user.getGlods()*tradeset.getGlodrate()<tradeset.getGlodout())
            message = "提示：您的提现金额需要 >= "+tradeset.getGlodout()+tradeset.getGlodunit();
        if(iSysCashorderService.selectSysCashorderList(sysCashorder).size()>0)
            message = "你还有待审核的提现订单，审核后才能再次体现！<a style='color:#19e'  href='/user/order'>查看订单</a>";
        model.put("message",message);
        model.put("tradeset",tradeset);
        model.put("user",user);
        model.put("ugroup",sysGroup);
        getabout(model);
        return "user/cash";
    }
    //提现处理
    @PostMapping(value = {"/cashout"})
    public String cashout(ModelMap model,@RequestParam("glods") Long glods, @RequestParam("from") int from, @RequestParam("account") String account) {
        commonhead(model);
        SysMember user = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysTradeset tradeset = iSysTradesetService.selectSysTradesetList(new SysTradeset()).get(0);
        SysGroup sysGroup = iSysGroupService.selectSysGroupByGroupid(user.getGroupid());
        SysCashorder sysCashorder = new SysCashorder();
        sysCashorder.setUserid(ShiroUtils.getSysMember().getUserid());
        sysCashorder.setState(0);
        String message = "";
        if(!StringUtils.contains(sysGroup.getRights(),"2")) {
            message = "提示：您没有提现权限";
            model.put("message",message);
            model.put("tradeset",tradeset);
            model.put("user",user);
            model.put("ugroup",sysGroup);
            getabout(model);
            return "user/cash";
        }
        if(user.getGlods()*tradeset.getGlodrate()<tradeset.getGlodout()) {
            message = "提示：您的提现金额需要 >= " + tradeset.getGlodout() + tradeset.getGlodunit();
            model.put("message",message);
            model.put("tradeset",tradeset);
            model.put("user",user);
            model.put("ugroup",sysGroup);
            getabout(model);
            return "user/cash";
        }
        if(iSysCashorderService.selectSysCashorderList(sysCashorder).size()>0) {
            message = "你还有待审核的提现订单，审核后才能再次体现！<a style='color:#19e'  href='/user/order'>查看订单</a>";
            model.put("message",message);
            model.put("tradeset",tradeset);
            model.put("user",user);
            model.put("ugroup",sysGroup);
            getabout(model);
            return "user/cash";
        }
        if(glods*tradeset.getGlodrate()>=tradeset.getGlodout()&&glods<= user.getGlods()) {
            sysCashorder.setTitle("提现");
            sysCashorder.setUserid(ShiroUtils.getSysMember().getUserid());
            sysCashorder.setGlods(glods);
            sysCashorder.setCash(String.valueOf(glods*tradeset.getGlodrate()));
            sysCashorder.setTradecash(glods*tradeset.getGlodrate()*sysGroup.getDivide());
            sysCashorder.setFrom(from);
            sysCashorder.setAccount(account);
            iSysCashorderService.insertSysCashorder(sysCashorder);
            getabout(model);
            return  redirect("/user/order");
        }
        message = "您最多提现" + user.getGlods() * tradeset.getGlodrate() + "元";
        model.put("message", message);
        model.put("tradeset", tradeset);
        model.put("user", user);
        model.put("ugroup", sysGroup);
        getabout(model);
        return "user/cash";
    }
    @GetMapping("/somepath")
    //在这里写这个函数感觉不是很合理
    public HashMap<Long, String> findParentIdsById(Long id, List<SysType> categories) {
        SysType category = categories.stream()
                .filter(c -> c.getTypeid().equals(id))
                .findFirst()
                .orElse(null);

        if (category != null) {
            parentIds.put(category.getTypeid(),category.getTypename());
            Long parentId = category.getPtypeid();
            if (parentId != null) {
                findParentIdsById(parentId, categories);
            }
        }

        return parentIds;
    }
    public  void commonhead(ModelMap modelMap)
    {
        SysMember sysMember = iSysMemberService.selectSysMemberByUserid(ShiroUtils.getSysMember().getUserid());
        SysGroup sysGroup = iSysGroupService.selectSysGroupByGroupid(sysMember.getGroupid());
        SysTradeset sysTradeset = new SysTradeset();
        List<SysTradeset> sysTradesets = iSysTradesetService.selectSysTradesetList(sysTradeset);
        Boolean edit = StringUtils.contains(sysGroup.getRights(),"14");
        Boolean delete = StringUtils.contains(sysGroup.getRights(),"15");
        Boolean iscoin = StringUtils.contains(sysGroup.getRights(),"2");
        String editdel = "";
        if(edit)
            editdel = editdel +  "<a href=\"/user/center/editdoc/#docid\" target=\"_blank\"><i class=\"fa fa-edit fa-lg\"></i></a>  ";
        if(delete)
            editdel = editdel + "<a submit-url=\\'{url:\"center/doc_del/#docid\",tip:\"彻底删除文档?\",back:[\"删除成功\", \"没有权限\"]}\\'><i class=\"fa fa-trash-o fa-lg\"></i></a>";
        SysDoc sysDoc = new SysDoc();
        sysDoc.setUserid(ShiroUtils.getSysMember().getUserid());
        //sysDoc.setState(1);
        sysDoc.setIsdel(0);
        List<SysDoc> docList = iSysDocService.selectSysDocList(sysDoc);
        Long readcount = 0l;
        Long downcount = 0l;
        for(int i=0;i<docList.size();i++)
        {
            readcount = readcount + docList.get(i).getReadcount();
            downcount = downcount + docList.get(i).getDowncount();

        }
        List<Integer> typeids = new ArrayList<>(Arrays.asList(11, 12, 30, 31, 32, 40, 41, 42, 50, 51, 52));
        Float coin = iSysGlodpotService.findCoinBydate(typeids,ShiroUtils.getSysMember().getUserid());
        if(coin==null)
            coin = 0f;
        modelMap.put("yesterday",coin);
        modelMap.put("iscoin",iscoin);
        modelMap.put("ugroup",sysGroup);
        modelMap.put("systradesets",sysTradesets.get(0));
        modelMap.put("doccount",docList.size());
        modelMap.put("readcount",readcount);
        modelMap.put("downcount",downcount);
        modelMap.put("editdel",editdel);
        modelMap.put("sysmember",sysMember);
        modelMap.put("url",getRequest().getRequestURI());
    }

}